﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.MaintenanceUpdates.CUiMessageBoxWithCheckBoxWindow
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.MaintenanceUpdates;

public class CUiMessageBoxWithCheckBoxWindow : TxWindow, IComponentConnector
{
  public DialogResult Result;
  public bool Checked;
  internal System.Windows.Controls.Image _image;
  internal TextBlock _text;
  internal System.Windows.Controls.CheckBox _checkBox;
  internal System.Windows.Controls.Button _buttonOk;
  internal System.Windows.Controls.Button _buttonCancel;
  private bool _contentLoaded;

  public CUiMessageBoxWithCheckBoxWindow() => this.InitializeComponent();

  public void Show(string text, string caption, string checkboxMessage, MessageBoxIcon icon = MessageBoxIcon.Asterisk)
  {
    this._text.Text = text;
    // ISSUE: explicit non-virtual call
    __nonvirtual (((Window) this).Title) = caption;
    this._checkBox.Content = (object) checkboxMessage;
    Icon icon1 = SystemIcons.Information;
    switch (icon)
    {
      case MessageBoxIcon.Hand:
        icon1 = SystemIcons.Error;
        break;
      case MessageBoxIcon.Question:
        icon1 = SystemIcons.Question;
        break;
      case MessageBoxIcon.Exclamation:
        icon1 = SystemIcons.Warning;
        break;
      case MessageBoxIcon.Asterisk:
        icon1 = SystemIcons.Information;
        break;
    }
    this._image.Source = (ImageSource) this.ConvertIconToImageSource(icon1);
    ((Window) this).ShowDialog();
  }

  private BitmapSource ConvertIconToImageSource(Icon icon)
  {
    return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
  }

  private void _buttonCancel_Click(object sender, RoutedEventArgs e)
  {
    this.Result = DialogResult.No;
    ((Window) this).Close();
  }

  private void _buttonOk_Click(object sender, RoutedEventArgs e)
  {
    this.Result = DialogResult.Yes;
    ((Window) this).Close();
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    System.Windows.Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/maintenanceupdates/cuimessageboxwithcheckboxwindow.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this._image = (System.Windows.Controls.Image) target;
        break;
      case 2:
        this._text = (TextBlock) target;
        break;
      case 3:
        this._checkBox = (System.Windows.Controls.CheckBox) target;
        break;
      case 4:
        this._buttonOk = (System.Windows.Controls.Button) target;
        this._buttonOk.Click += new RoutedEventHandler(this._buttonOk_Click);
        break;
      case 5:
        this._buttonCancel = (System.Windows.Controls.Button) target;
        this._buttonCancel.Click += new RoutedEventHandler(this._buttonCancel_Click);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
